package com.otupia.acs.spring.Impl;

import org.apache.log4j.Logger;

import com.otupia.acs.entity.UserInfo;
import com.otupia.acs.spring.api.Authenticator;
import com.otupia.acs.spring.dao.UserDao;

public class AuthenticatorBeanSpring implements Authenticator
{
	Logger logger = Logger.getLogger(AuthenticatorBeanSpring.class);
	UserDao userDao;
	
	public UserDao getUserDao()
	{
		return userDao;
	}

	public void setUserDao(UserDao userDao)
	{
		this.userDao = userDao;
	}

	@Override
	public UserInfo login(UserInfo userInfo)
	{
		logger.info("calling function AuthenticatorBeanSpring"
				+ "#login with arguments : [" + userInfo + "]");
		
		UserInfo userInfoFounded = this.userDao.findUserByNameAndPwd(userInfo.getName(), userInfo.getPassword());
		
		logger.info("exiting function AuthenticatorBeanSpring"
				+ "#login with result : [" + userInfo + "]");
		
		return userInfoFounded;
	}

	@Override
	public void logout(String id)
	{
		logger.info("calling function AuthenticatorBeanSpring"
				+ "#logout with arguments : [" + id + "]");
		
		logger.fatal("doing nothing!!");
		
		logger.info("exiting function AuthenticatorBeanSpring"
				+ "#logout with result : [" + id + "]");
	}
}
